<template lang="pug">
.welfare-model(v-if="data")
  el-dialog(
    width="30%",
    title="抢到红包",
    :visible.sync="showModal",
    :before-close="beforeCloseHandler")
    .top.tac
      a.icon(:href="data.linkurl")
        img(:src="baseUrl + data.logo")
      p.text {{data.totalmoney ? '恭喜你' : '很遗憾'}}
      p.text {{data.totalmoney ? '抢到红包 '+ data.totalmoney +' 元' : '红包已经领过了'}}

      p.btn.tac(@click="showDesc") 查看活动规则

    .bottom.tac
      el-button(type="primary", size="small", @click="showRecord") 领取记录
      el-button(type="warning", size="small", @click="withdraw") 提现
      el-button(type="success", size="small", @click="showShare") 我要分享
</template>

<script>
import modalMixin from '@/mixins/modal'
import { Dialog } from 'vant'
export default {
  name: 'welfareModal',
  mixins: [modalMixin],
  data() {
    return {
      baseUrl: $globalconfig.URLS.API,
      data: null,
    }
  },
  mounted() {
    this.$vgo.on('modal:welfale', data => {
      this.data = data
      this.openModal()
    })
  },
  methods: {
    showShare() {
      this.$vgo.emit('model:share')
    },
    showRecord() {
      this.$vgo.emit('welfare:history')
    },
    withdraw() {
      window.location.href = $globalconfig.URLS.USER
    },
    showDesc() {
      let msg = this.data.description

      this.$alert(msg, '活动规则', {
        confirmButtonText: '确定'
      })
    }
  }
}
</script>

<style lang="stylus" scoped>
@import '../../../assets/styles/welfare.styl'

</style>
